<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <button type="button">向页面中插入数据</button>
    <ul id="list"></ul>

    <script>
        var btn = document.querySelector('button')
        var list = document.querySelector('#list')

        var arr = [{name:"刘德华",age:58,sex:"男"},{name:"郭富城",age:56,sex:"男"},{name:"黎明",age:54,sex:"男"},{name:"张学友",age:57,sex:"男"}]
         
        /*for(var i = 0; i < arr.length; i++){

            var oLi = document.createElement('li')

            var oLt = document.createElement('div')
            oLt.innerText = arr[i].name + "的基本信息"

            var oLc = document.createElement('div')
            var p1 = document.createElement('p')
            p1.innerText = '姓名：' + arr[i].name
            oLc.appendChild(p1)
            var p2 = document.createElement('p')
            p2.innerText = '年龄：' + arr[i].age
            oLc.appendChild(p2)
            var p3 = document.createElement('p')
            p3.innerText = '性别：' + arr[i].sex
            oLc.appendChild(p3)

            oLi.appendChild(oLt)
            oLi.appendChild(oLc)
            list.appendChild(oLi)
        }*/

        for(var i = 0; i < arr.length; i++){
            list.innerHTML += "<li><div>"+arr[i].name+"的基本信息"+"</div><div><p>"+'姓名：'+arr[i].name+"</p><p>"+'年龄：'+arr[i].age+"</p><p>"+'性别：'+arr[i].sex+"</p></div></li>"
        }
    </script>
</body>
</html>